#include <stdio.h>

int _main(int argc, char* argv[], char* envp[]) {
    // 打印命令行参数
    printf("Number of arguments: %d\n", argc);
    for (int i = 0; i < argc; i++) {
        printf("argv[%d]: %s\n", i, argv[i]);
    }
    
    // 打印环境变量
    printf("\nEnvironment Variables:\n");
    for (int i = 0; envp[i] != NULL; i++) {
        printf("%s\n", envp[i]);
    }

    return 0;
}

// 解析环境变量的值
char *get_env(char **envp,char *env){
    char *p,*q;
    while (*envp!=NULL){
        p=*envp,q=env;
        while (*p!='\0'||*q!='\0'){
            if (*p!=*q) break;
            ++p,++q;
        }
        if (*q!='\0')
            ++envp;
        else if (*p=='=')
            return ++p;
    }
    return NULL;
}

int main(int argc, char *argv[], char **envp){
    if (argc>1){
        char *p=get_env(envp,argv[1]);
        if (p!=NULL)
            printf("%s\n",p);
    }
    return 0;
}